﻿using System;
using System.Collections.Generic;
using System.Text;

namespace ChangeProblem.Logic
{
    public class Change
    {
        public  int[] GetChange(decimal change, decimal[] nominalvalue,int[] moneyLocker)
        {

            int[] changePlan = new int[nominalvalue.Length];

            for (int i = 0; i < nominalvalue.Length; i++)
            {
                changePlan[i] = (int)(change / nominalvalue[i]);
                if (changePlan[i] > moneyLocker[i])
                    changePlan[i] = moneyLocker[i];
                change -= changePlan[i] * nominalvalue[i];
            }

            return changePlan;
        }

        public decimal ChangeAmount(double price, double payment)
        {
            return (decimal)(payment - price);
        }

    }
}
